import 'package:injectable/injectable.dart';
import 'dio_client.dart';
import 'package:dio/dio.dart';
import 'base_response.dart';

@singleton
class Api {
  final DioClient _dioClient;

  Api(this._dioClient);

  Future<BaseResponse<int>> getCurrentTime(String macAddress) async {
    try {
      final response = await _dioClient.instance.get(
        '/cabinetTerminal/getCurrentTimestamp',
        queryParameters: {'macAddress': macAddress},
      );
      return BaseResponse<int>.fromJson(response.data, (data) => data as int);
    } catch (e) {
      rethrow;
    }
  }
}
